package q367_isPerfectSquare;

public class Solution {

    public boolean isPerfectSquare(int num) {
        long l = 0, r = num;
        while (r - l > 1) {
            if (((l + r) / 2) * ((l + r) / 2) > num) {
                r = (int)(l + r) / 2;
            } else {
                l = (int)(l + r) / 2;
            }

        }
        return r * r == num || l * l == num;
    }
}
